package com.ihr360.cnb;

import com.ihr360.cnb.filter.Ihr360CNBAggregateAuthUserResolver;
import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

@EnableFeignClients(basePackages = {"com.ihr360.sharedservice.api", "com.ihr360.cnb.module","com.ihr360.excel.aggregatemodule","com.ihr360.authority.embed.auth"})
@SpringBootApplication
@EnableCircuitBreaker
//@EnableEurekaClient
@ComponentScan(basePackages = {"com.ihr360.cnb", "com.ihr360.shared.message", "com.ihr360.shared.advice", "com.ihr360.sharedservice", "com.ihr360.excel", "com.ihr360.feign", "com.ihr360.rest.filter", "com.ihr360.admin.client", "com.ihr360.authority.embed.auth"})
@PropertySource(value = "classpath:git.properties", ignoreResourceNotFound = true)
@EnableAsync
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class Ihr360CNBAggregateApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(Ihr360CNBAggregateApplication.class, args);
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        super.addArgumentResolvers(argumentResolvers);
        argumentResolvers.add(new Ihr360CNBAggregateAuthUserResolver());
    }

    /**
     * 修改feign的默认log级别，默认为NONE， 什么都不输出
     *
     * @return
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

}
